package com.cn.wanxi.service;

import com.cn.wanxi.dao.NewsDao;
import com.cn.wanxi.model.NewsModel;

public class NewsService {
    public static final String NAME="aaa";
    public NewsService(String title) {

    }


    static {
        System.out.println("静态代码块");
    }
    {
        System.out.println("代码块");
    }

    public NewsService() {
        System.out.println("无参数的构造方法");
    }

    public static void main(String[] args) {

    }
//    public NewsService NewsService() {
//        aa();//如果没有返回值，则只是调用方法执行代码
//        String bb = bb();//如果有返回值，我们一般会用一个容器去接收
//        return null;
//    }

    public void aa() {
    }

    public String bb() {
        return "";
    }

    /**
     * 对首页新闻进行赋值
     *
     * @return
     */
    public NewsModel[] getNewsModelsForHomePage() {
        int length = NewsDao.TITLE_FOR_HOME_PAGE.length;
        NewsModel[] newsModels = new NewsModel[length];
        for (int i = 0; i < length; i++) {
            NewsModel newsModel = new NewsModel();
            newsModel.setTitle(NewsDao.TITLE_FOR_HOME_PAGE[i]);
            newsModel.setContent(NewsDao.CONTENT_FOR_HOME_PAGE[i]);
            newsModels[i] = newsModel;
        }
        return newsModels;
    }

    /**
     * 对新闻页面新闻进行赋值
     *
     * @return
     */
    public NewsModel[] getNewsModelsForNewsPage() {
        int length = NewsDao.TITLE_FOR_NEWS_PAGE.length;
        NewsModel[] newsModels = new NewsModel[length];
        for (int i = 0; i < length; i++) {
            NewsModel newsModel = new NewsModel();
            newsModel.setTitle(NewsDao.TITLE_FOR_NEWS_PAGE[i]);
            newsModel.setPublishTime(NewsDao.PUBLISH_FOR_NEWS_PAGE[i]);
            newsModel.setImg(NewsDao.IMG_FOR_NEWS_PAGE[i]);
            newsModels[i] = newsModel;
        }
        return newsModels;
    }


}
